package com.tanhua.server.controller;

import com.github.tobato.fastdfs.domain.conn.FdfsWebServer;

import com.github.tobato.fastdfs.service.FastFileStorageClient;

import com.tanhua.model.vo.VoiceVo;
import com.tanhua.server.service.VoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Description:
 * @Create by: wanglei
 * @Date: 2021/11/6 18:01
 */
//桃花传音
@RestController
@RequestMapping("/peachblossom")
public class VoiceController {

    @Autowired
    private VoiceService voiceService;

    //保存发出的语音
    @PostMapping
    public ResponseEntity saveVoice(MultipartFile soundFile) throws IOException {
        voiceService.saveVoice(soundFile);
        return ResponseEntity.ok(null);
    }

    //随机推荐一条语音
    @GetMapping
    public ResponseEntity getRandomVoice(){
        VoiceVo voiceVo = voiceService.getRandomVoice();
        return ResponseEntity.ok(voiceVo);
    }
}
